<?php
session_start();
//var_dump($_SESSION);
//echo count($_SESSION);
if(!isset($_SESSION)){
	header('location:login.php');
}

include '../config/db_config.php';
include '../lib/kelola_review.php';

$id_techno = $_SESSION['ID_TECHNOPRENEUR'];

$kelola_review = new kelola_review();

$res = $kelola_review->select_review($id_techno);

$review = array();

while($row = mysql_fetch_assoc($res)) {
	$review[] = $row;
}

?>
<html>
  <head>
    <title>Smart Commerce</title>
    <link href="../css/bootstrap.min.css" rel="stylesheet">
	<style type="text/css">
      body {
        padding-top: 60px;
        padding-bottom: 40px;
      }
    </style>
    <link href="../css/bootstrap-responsive.min.css" rel="stylesheet">
	<script src="../js/jquery-1.7.2.min.js"></script>
	<script src="../js/bootstrap.min.js"></script>
</head>
<body>
	<div class="navbar navbar-inverse navbar-fixed-top">
		<div class="navbar-inner">
			<div class="container">
			<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
			</a>
			
			<a class="brand" href="home_technopreneur.php">Beranda</a>
			<a class="brand">Tentang Kami</a>
			<a class="brand">Kontak</a>
			
				<div class="nav-collapse collapse">
				<form class="navbar-form pull-right" method="post">
				</form>
			<div class="navbar-form pull-right">
				<a href="profil_technopreneur.php" class="btn btn-small btn-primary">Profil</a>
				<a href="../logout.php" class="btn btn-small btn-primary">Logout</a>
			</div>
				
			    </div>
			</div>
		</div>
    </div>
	
		<div class="container">
			<div class="hero-unit"style="background-image:url('../images/header.jpg');" >
				<h1>Smart Commerce</h1>
				<blockquote class="pull-right"> 
					<p>Website khusus Technopreneur Surabaya</p>
				</blockquote>
			</div>
  
			<ul class="breadcrumb">
				<li class="active">Home</li>
			</ul>
			<div class="jumbotron">
				<h1 style="text-align:center">Hai, Selamat Datang di Halaman Technopreneur !</h1>
				<p style="text-align:center" class="lead">Halaman Technopreneur Website Smart Commerce</p>
				<center><a class="btn btn-large btn-info" type="button" href="tambah_produk.php">Tambah Produk</a> <a class="btn btn-large btn-success" type="button" href="kelola_produk_techno.php">Kelola Produk</a></center>
			</div>
			
			<br>
			<h3>Review Produk</h3>
			<div class="tabbable"> <!-- Only required for left/right tabs -->
				<ul class="nav nav-tabs">
					<li  class="active"><a href="#tab1" data-toggle="tab">Semua</a></li>
					<li><a href="#tab2" data-toggle="tab">Belum Dikonfirmasi</a></li>
					<li><a href="#tab3" data-toggle="tab">Sudah Dikonfirmasi</a></li>
				</ul>
				<div class="tab-content">
					<div class="tab-pane active" id="tab1">
						<table class="table table-bordered table-hover" style="width:600;" border="1" cellspacing="0" cellpadding="2">
						<?php
						if(!isset($review)){
							echo '<a href="#review_produk" class="muted">Belum ada review</a>';
						}
						else{
							for($i = 0; $i < count($review); $i++){
								echo '<tr>';
								echo '<td>';
								echo '<small class="text-info"><a href="informasi_produk.php?id='.$review[$i]['ID_PRODUK'].'" target="_blank">'.$review[$i]['NAMA_PRODUK'].'</a>';
								if($review[$i]['CONFIRMED']){
									echo '<strong class="muted"> (Confirmed)</strong>';
								}
								else{
									echo '<strong class="muted"> (Unconfirmed)</strong>';
								}
								echo '</small>';
								echo '<br><small class="muted">'.$review[$i]['WAKTU'].' by <span class="text-warning">'.$review[$i]['EMAIL_GUEST'].'</span></small><br>'.$review[$i]['REVIEW_PRODUK'];
								echo '</td>';
								echo '</tr>';
							}
						}
						?>
						</table>
					</div>
					<div class="tab-pane" id="tab2">
						<table class="table table-bordered table-hover" style="width:600;" border="1" cellspacing="0" cellpadding="2">
						<?php
						if(!isset($review)){
							echo '<a href="#review_produk" class="muted">Belum ada review</a>';
						}
						else{
							for($i = 0; $i < count($review); $i++){
								if(!$review[$i]['CONFIRMED']){
									echo '<tr>';
									echo '<td>';
									//echo '<div class="row">';
									echo '<div class="span7">';
									echo '<small class="text-info"><a href="informasi_produk.php?id='.$review[$i]['ID_PRODUK'].'" target="_blank">'.$review[$i]['NAMA_PRODUK'].'</a>';
									echo '</small>';
									echo '<br><small class="muted">'.$review[$i]['WAKTU'].' by <span class="text-warning">'.$review[$i]['EMAIL_GUEST'].'</span></small><br>'.$review[$i]['REVIEW_PRODUK'];
									echo '</div>';
									echo '<div class="span2" style="vertical-align:middle;">';
									echo '<a class="btn btn-info" onclick="confirmed('.$review[$i]['ID_REVIEW_PRODUK'].')" >Confirm</a>';
									echo '</div>';
									//echo '</div>';
									echo '</td>';
									echo '</tr>';
								}
							}
						}
						?>
						</table>
					</div>
					<div class="tab-pane" id="tab3">
						<table class="table table-bordered table-hover" style="width:600;" border="1" cellspacing="0" cellpadding="2">
						<?php
						if(!isset($review)){
							echo '<a href="#review_produk" class="muted">Belum ada review</a>';
						}
						else{
							for($i = 0; $i < count($review); $i++){
								if($review[$i]['CONFIRMED']){
									echo '<tr>';
									echo '<td>';
									//echo '<div class="row">';
									echo '<div class="span7">';
									echo '<small class="text-info"><a href="informasi_produk.php?id='.$review[$i]['ID_PRODUK'].'" target="_blank">'.$review[$i]['NAMA_PRODUK'].'</a>';
									echo '</small>';
									echo '<br><small class="muted">'.$review[$i]['WAKTU'].' by <span class="text-warning">'.$review[$i]['EMAIL_GUEST'].'</span></small><br>'.$review[$i]['REVIEW_PRODUK'];
									echo '</div>';
									echo '<div class="span2" style="vertical-align:middle;">';
									echo '<a class="btn btn-warning" onclick="unconfirm('.$review[$i]['ID_REVIEW_PRODUK'].')" >Unconfirm</a>';
									echo '</div>';
									//echo '</div>';
									echo '</td>';
									echo '</tr>';
								}
							}
						}
						?>
						</table>
					</div>
			  </div>
			</div>
			
		</div>
		<script>
		function unconfirm(id){
			var c = confirm("Anda akan membatalkan konfirmasi review ini. Lanjutkan?");
			if(c){
				window.location="../unconfirm_review.php?id="+id;
			}
		}
		
		function confirmed(id){
			var c = confirm("Anda akan mengonfirmasi review produk ini. Lanjutkan?");
			if(c){
				window.location="../confirm_review.php?id="+id;
			}
		}
		</script>
  </body>
</html>